const { generateAiSuggestions } = require('../services/aiService');

const getAiSuggestions = async (req, res) => {
  try {
    const { currentWeather, forecastWeather, cityName } = req.body;

    if (!currentWeather || !forecastWeather || !cityName) {
      return res.status(400).json({ error: '缺少必要的天气信息或城市名称。' });
    }

    const aiSuggestions = await generateAiSuggestions(currentWeather, forecastWeather, cityName);

    if (aiSuggestions.error) {
      return res.status(500).json({ error: '生成AI建议失败', details: aiSuggestions.error });
    }

    res.json(aiSuggestions);
  } catch (error) {
    console.error('获取AI建议失败:', error);
    res.status(500).json({ error: '获取AI建议失败', details: error.message });
  }
};

module.exports = { getAiSuggestions }; 